package server.handler.groupHandler;

import com.alibaba.fastjson.JSONObject;
import common.EnvelopeMessage;
import server.dao.GroupDao;
import server.handler.SimpleHandler;
import server.session.Session;

public class GroupResponseHandler implements SimpleHandler {
    @Override
    public void handle(EnvelopeMessage msg, Session session) {
        JSONObject body = msg.getBody();

        Integer fromId = body.getInteger("fromId");
        Integer groupId = body.getInteger("groupId");
        Boolean accept = body.getBoolean("accept");
        if (accept) {
            new GroupDao().updateGroupShip(fromId,groupId,1,1);
        } else {
            new GroupDao().updateGroupShip(fromId,groupId,0,-1);
        }

    }
}
